"""
Copyright (c) 2022 Huawei Technologies Co.,Ltd.

openGauss is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:

          http://license.coscl.org.cn/MulanPSL2

THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details.
"""
"""
Case Type   : ustore-Consistency
Case Name   : 清理环境 
Create At   : 2022/10/28
Owner       : opentestcase004
Description :
    1.清理环境
Expect      :
    1.成功
History     :
    modified by opentestcase004 2022/10/24:修改用例,触发执行
    modified by opentestcase004 2022/10/28:修改用例,触发执行
    modified by opentestcase004 2022/11/15:修改用例,触发执行
"""

import os
import unittest
from testcase.utils.Logger import Logger
from testcase.utils.CommonSH import CommonSH
from testcase.utils.Constant import Constant


class CONSISTENCY(unittest.TestCase):
    def setUp(self):
        self.pri_sh = CommonSH('PrimaryDbUser')
        self.constant = Constant()
        self.log = Logger()
        self.log.info(f'-----{os.path.basename(__file__)} start-----')
        self.schema1 = 's_ustore_consistency_01'
        self.schema2 = 's_ustore_consistency_02'

    def test_ustore_consistency(self):
        text1 = 'step1:清理环境 expect:成功'
        self.log.info(text1)
        drop_schema = self.pri_sh.execut_db_sql(
            f'''drop schema {self.schema1} cascade;
            drop schema {self.schema2} cascade;''')
        self.log.info(drop_schema)
        self.assertEqual(
            drop_schema.count(self.constant.DROP_SCHEMA_SUCCESS_MSG), 2,
            '执行失败' + text1)

    def tearDown(self):
        self.log.info('-----无需清理环境-----')
        self.log.info(f'-----{os.path.basename(__file__)} end-----')
